<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>二维数组转置</title>
    <style>
            a:link,a:visited{
                color: #222;text-decoration: none;}
           a:hover{color: #fd4913;}
       </style>
   
</head>
<body>
    <h2>二维数组转置</h2>
    <script>
        var arr=[['a','b','c'],['d','e','f'],['g','h','i'],['j','k','l']];
        var res=[];
        for(var i=0;i<arr[0].length;i++){
            res[i]=[];
            for(var j=0;j<arr.length;j++){
                res[i][j]=arr[j][i];
            }
        }
        console.group('转置前：');
        console.log(arr);
        //console.groupEnd();
        console.group('转置后:');
        console.log(res);
        //console.groupEnd();
    </script>
    <p><a href="default.html">返回目录</a></p>
    <p><a href="第三章.html">返回第三章</a></p>
    <p><a href="猴子选大王.html">下一题</a></p>
    <p><a href="第四章.html">下一章</a></p>
</body>
</html>